# -*- coding: utf-8 -*-
"""
Created on Thu Dec 16 01:25:11 2021

@author: 刘长奇
"""

import numpy as np
import pandas as pd
import matplotlib as plt

train_data=np.load("t10k-images.npy")#60000,784
train_label=np.load("t10k-labels.npy")#60000
test_data=np.load("train-images.npy")#10000,784
test_label=np.load("train-labels.npy")#10000
class_names = ['T-shirt','Trouser','Pullover','Dress','Coat','Sandal','Shirt','Sneaker','Bag','Ankle boot']


from sklearn.neural_network import MLPClassifier
clf_class= MLPClassifier(solver='adam', learning_rate_init=0.001,activation='logistic', alpha=1e-5,hidden_layer_sizes=(200,10), random_state=1,max_iter=2000)
clf_class.fit(train_data,train_label)
#sklearn神经网络学习，隐藏层两层，第一层30个节点，第二层24个节点，最多迭代2000次

y_pred=[]
j=0
for i in range(np.shape(test_data)[0]):
    y_pred.append(clf_class.predict([test_data[i]]))
for i in range(np.shape(test_data)[0]):
    if y_pred[i]==test_label[i]:
        j=j+1
print(j/10000)
#训练集准确率计算：0.8519